package com.outdoor.server.controller.admin;


import com.outdoor.common.result.PageResult;
import com.outdoor.common.result.Result;
import com.outdoor.pojo.dto.NodePageQueryDTO;
import com.outdoor.pojo.vo.NodeVO;
import com.outdoor.server.service.NodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/node")
@Slf4j
public class NodeController {
    @Autowired
    private NodeService nodeService;

    /**
     * 分页查询节点信息
     * @param nodePageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> page(NodePageQueryDTO nodePageQueryDTO) {
        PageResult pageResult = nodeService.page(nodePageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 根据id查询节点信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result<NodeVO> getById(@PathVariable Long id) {
        NodeVO nodeVO = nodeService.getById(id);
        return Result.success(nodeVO);
    }
}
